<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	  xmlns:h="http://java.sun.com/jsf/html"
	  xmlns:f="http://java.sun.com/jsf/core">

<h:head>
	<link rel="stylesheet" href="../resources/css/style.css" />
	<link rel="stylesheet" href="../resources/css/superfish.css" />
	<script type="text/javascript" src="../resources/js/lib/jquery.js"></script>
	<script type="text/javascript" src="../resources/js/lib/jquery.tools.js"></script>
	<script type="text/javascript" src="../resources/js/lib/jquery.validate.js"></script>
	<script type="text/javascript" src="../resources/js/lib/superfish.js"></script>
	<script type="text/javascript" src="../resources/js/navigation.js"></script>
	<script type="text/javascript" src="../resources/js/onload.js"></script>
</h:head>

<h:body>

	<!-- Lista de usuários -->
	<f:view>
		<div class="form list">

			<h1><h:outputText value="Gerenciamento de usuários" /></h1>

			<h:form>

				<h:dataTable styleClass="data" value="#{users.users}" var="user" varStatus="status"
						columnClasses="value,value,value,value,action,action,action">

					<h:column headerClass="id">
						<f:facet name="header">
							<h:outputText value="ID" />
						</f:facet>
						<h:outputText value="#{status.index + 1}" />
						<f:attribute name="width" value="50px" />
					</h:column>

					<h:column headerClass="email">
						<f:facet name="header">
							<h:outputText value="E-mail" />
						</f:facet>
						<h:outputText value="#{user.email}" />
					</h:column>

					<h:column headerClass="pwd">
						<f:facet name="header">
							<h:outputText value="Senha" />
						</f:facet>
						<h:outputText value="#{user.password}" />
					</h:column>

					<h:column headerClass="status">
						<f:facet name="header">
							<h:outputText value="Status" />
						</f:facet>
						<h:outputText value="#{user.status}" />
					</h:column>

					<h:column headerClass="action">
						<h:commandLink value="Ativar" action="#{users.activate(user.loginId)}">
							<f:ajax execute="@this" render="@form" />
						</h:commandLink>
					</h:column>

					<h:column headerClass="action">
						<h:commandLink value="Desativar" action="#{users.deactivate(user.loginId)}">
							<f:ajax execute="@this" render="@form" />
						</h:commandLink>
					</h:column>

					<h:column headerClass="action">
						<h:commandLink value="Remover" action="#{users.remove(user.loginId)}">
							<f:ajax execute="@this" render="@form" />
						</h:commandLink>
					</h:column>

				</h:dataTable>

			</h:form>

		</div>
	</f:view>
</h:body>

</html>
